<template>
  <div class="left-box">
    <div class="box1">
      <div class="title-box">
        <commonItemTitle title="服务企业"></commonItemTitle>
      </div>
      <div class="content-box">
        <div class="msg-box">
          <div class="label-box">服务企业数：</div>
          <div class="value">123</div>
        </div>
        <div class="chart-box">
          <img src="@/assets/imgs/left1-bing.png" alt="" class="chart" />
        </div>
        <div class="right-bt-line"></div>
        <div class="black-box">一、1</div>
      </div>
    </div>
    <div class="box2">
      <div class="title-box">
        <commonItemTitle title="进出口数据"></commonItemTitle>
      </div>
      <div class="content-box">
        <div class="msg-title">进出口货值Top3商品</div>
        <div class="list-box">
          <div class="item-box" v-for="(item, index) in 3" :key="item">
            <div class="left-num">
              <img src="@/assets/imgs/top1.png" alt="" v-if="index === 0" />
              <img src="@/assets/imgs/top2.png" alt="" v-if="index === 1" />
              <img src="@/assets/imgs/top3.png" alt="" v-if="index === 2" />
            </div>
            <div class="right-msg">
              <div class="top-msg">
                <div class="label">转基因黄大豆</div>
                <div class="value">329,907万元</div>
              </div>
              <div class="bot-pro">
                <el-progress
                  :percentage="30 * item"
                  :stroke-width="15"
                  :show-text="false"
                  striped
                  striped-flow
                />
              </div>
            </div>
          </div>
        </div>
        <div class="black-box">一、2</div>
      </div>
    </div>
    <div class="box3">
      <div class="title-box">
        <commonItemTitle title="贸易数据"></commonItemTitle>
        <div class="unit">单位：亿元</div>
      </div>
      <div class="content-box">
        <div class="chart-box" id="left3Chart"></div>
        <div class="black-box">一、3</div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import {  onMounted } from "vue";
import commonItemTitle from "@/components/commonItemTitle.vue";
import * as echarts from "echarts";

const renderLeft3Chart = () => {
  let myChart = echarts.init(document.getElementById("left3Chart")!);
  let option = {
    grid: {
      top: 26,
      bottom: 74,
      left: 26,
      right: 26,
    },
    xAxis: {
      type: "category",
      data: [
        `“新三样”出口额`,
        "跨境电商海运出口额",
        `对“一带一路”共建国家出口额`,
        "高新技术产品迸出口额",
      ],
      //   data: ["1", "3", "3", "4"],
      axisLine: {
        lineStyle: {
          color: "#4867A7",
        },
      },
      axisLabel: {
        color: "#4BC8FF",
        fontSize: 13,
        formatter: function (val: any) {
          var strs = val.split(""); //字符串数组
          var str = "";
          for (var i = 0, s; (s = strs[i++]); ) {
            //遍历字符串数组
            str += s;
            if (!(i % 4)) str += "\n"; //按需要求余
          }
          return str;
        },
      },
    },
    yAxis: {
      type: "value",
      axisLabel: {
        show: false,
      },
      splitLine: {
        lineStyle: {
          type: [2, 1],
          color: "#4867A7",
        },
      },
    },
    series: [
      {
        data: [3900, 555, 7888, 788],
        type: "bar",
        itemStyle: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            { offset: 0, color: " #00CEFF" },
            { offset: 1, color: "#5294FF" },
          ]),
        },
        barWidth: 20,
      },
    ],
  };
  option && myChart.setOption(option);

  window.addEventListener("resize", () => {
    myChart.resize();
  });
};

onMounted(() => {
  renderLeft3Chart();
});
</script>

<style scoped lang="scss">
.left-box {
}
.box1 {
  display: flex;
  flex-direction: column;
  align-items: end;
  .title-box {
  }
  .content-box {
    position: relative;
    width: 394px;
    height: 277px;
    margin-top: -2px;
    background-image: url(@/assets/imgs/left1Bg.png);
    background-size: cover;
    background-repeat: no-repeat;
    .msg-box {
      display: flex;
      justify-content: center;
      align-items: center;
      height: 45px;
      margin-top: 27px;
      .label-box {
        font-family: PingFang SC, PingFang SC;
        font-weight: 600;
        font-size: 14px;
        color: #6cf3ff;
        line-height: 24px;
        text-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
      }
      .value {
        font-family: Avenir, Avenir;
        font-weight: 900;
        font-size: 24px;
        color: #6cf3ff;
        line-height: 24px;
        text-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
      }
    }
    .chart-box {
      position: relative;
      display: flex;
      justify-content: center;
      align-items: center;
      height: calc(100% - 72px);
      .chart {
        width: 166px;
        height: 100px;
      }
    }
    .right-bt-line {
      position: absolute;
      right: 5px;
      bottom: 3px;
      width: 47px;
      height: 43px;
      border-right: 2px solid #45e3ff;
      border-bottom: 2px solid #45e3ff;
    }
  }
}
.box2 {
  display: flex;
  flex-direction: column;
  align-items: end;
  margin: 15px 0;
  .title-box {
  }
  .content-box {
    position: relative;
    width: 394px;
    height: 246px;
    margin-top: -2px;
    // background: linear-gradient(
    //   180deg,
    //   rgba(0, 206, 255, 0.8) 0%,
    //   rgba(37, 61, 252, 0.3) 100%
    // );
    background: rgb(1, 59, 114);
    border-radius: 0px 0px 0px 0px;

    .msg-title {
      height: 20px;
      margin-top: 19px;
      text-align: center;
      font-weight: 600;
      font-size: 14px;
      color: #6cf3ff;
      line-height: 24px;
      text-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
    }
    .list-box {
      padding: 20px;
      box-sizing: border-box;
      .item-box {
        display: flex;
        height: 34px;
        .left-num {
          padding-top: 5px;
          box-sizing: border-box;
          img {
            width: 27px;
            height: 12px;
          }
        }
        .right-msg {
          flex: 1;
          margin-left: 10px;
          .top-msg {
            display: flex;
            justify-content: space-between;
            height: 20px;
            margin-bottom: 6px;
            .label {
              font-size: 14px;
              color: #6cf3ff;
              text-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
            }
            .value {
              font-size: 14px;
              color: #6cf3ff;
              text-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
            }
          }
          .bot-pro {
            ::v-deep(.el-progress-bar__outer) {
              height: 8px !important;
              background-color: rgba(24, 202, 255, 0.2);
            }
          }
        }
      }
      .item-box:nth-of-type(2) {
        margin: 20px 0;
      }
    }
  }
}
.box3 {
  display: flex;
  flex-direction: column;
  align-items: end;
  .title-box {
    position: relative;
    .unit {
      position: absolute;
      top: 3px;
      left: 130px;
      display: flex;
      align-items: center;
      height: 44px;

      font-weight: 400;
      font-size: 13px;
      color: #4bc8ff;
    }
  }
  .content-box {
    position: relative;
    width: 394px;
    height: 254px;
    margin-top: -2px;
    // background: linear-gradient(
    //   180deg,
    //   rgba(0, 206, 255, 0.8) 0%,
    //   rgba(37, 61, 252, 0.3) 100%
    // );
    background: rgb(1, 76, 134);
    .chart-box {
      width: 100%;
      height: 100%;
    }
  }
}
.black-box {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 56px;
  height: 30px;
  background: #000000;
  font-family: PingFang SC, PingFang SC;
  font-weight: 600;
  font-size: 13px;
  color: #76eaff;
  border-radius: 4px 4px 4px 4px;
  opacity: 0.5;
}
</style>
